import request from '@/utils/request'
export const login = (data) => request.post('/user/login', data)
export const register = (data) => request.post('/user/register', data)
export const getUserInfo = () => request.get('/user/info')
export const updateUserInfo = (data) => request.put('/user/info', data)

/**
 * 根据ID获取用户详情
 * @param {number} id - 用户ID
 * @returns {Promise}
 */
export function getUserById(id) {
    return request({
        url: `/users/${id}`,
        method: 'get'
    });
}


// 发送重置密码的验证码
export function sendResetCode(data) {
    return request({
        url: '/users/reset/code',
        method: 'post',
        data
    })
}

// 验证重置密码的验证码
export function verifyResetCode(data) {
    return request({
        url: '/users/reset/verify',
        method: 'post',
        data
    })
}

// 重置密码
export function resetPassword(data) {
    return request({
        url: '/users/reset',
        method: 'post',
        data
    })
}
